﻿@{
    ViewBag.Title = "Index";
    ViewBag.FirstPage = "公告管理";
    ViewBag.LastPage = "公告列表";
    Layout = "~/Views/MasterPage.cshtml";
}
<script src="/Source/layui/layui.all.js"></script>
<script src="/Source/layui/layui.js"></script>
<link href="/Source/layui/css/layui.css" rel="stylesheet" />
<script src="~/Scripts/jquery-3.4.1.min.js"></script>


<script>
    var AllPage = parseInt("@ViewBag.allpage");
    var PageNum = parseInt("@ViewBag.pageNum");
    var pageSize = 1;

    $(function () {
        //下一页
        $("#nextPage").click(function () {
            PageNum++;
            if (PageNum >= AllPage)
                PageNum = AllPage;
            //: "{controller}/{action}/{pageNum}/{pageSize}",
            window.location.href = "/Notice/Index/" + PageNum + "/" + pageSize + "";
        });

    });
</script>
<div class="am-g">

    <div class="am-u-md-6 am-cf">
        <div class="am-fl am-cf">
            <div class="am-btn-toolbar am-fl">
                <div class="am-btn-group am-btn-group-xs">
                    <button type="button" class="am-btn am-btn-default" id="btnAdd"><span class="am-icon-plus"></span>新增</button>
                    @*<button type="button" class="am-btn am-btn-default" id="btnExcel"><span class="am-icon-save"></span>导入Excel</button>*@

                </div>

                <div class="am-form-group am-margin-left am-fl">
                </div>
            </div>
        </div>
    </div>

    <div class="am-u-sm-12">
        <form class="am-form">
            <table class="am-table am-table-striped am-table-hover table-main">
                <thead>
                    <tr>

                        <th class="table-title">标题</th>
                        <th class="table-author">发布时间</th>
                        <th class="table-date">操作时间</th>
                        <th class="table-set">操作</th>
                    </tr>
                </thead>
                <tbody>
                    @{
                        var noticeList = ViewBag.noticeList as List<Model.OA_Notice>;
                        if (noticeList.Count != 0)
                        {
                            foreach (var item in noticeList)
                            {
                        <tr>
                            <td><a href="#">@item.Title</a></td>
                            <td>@item.InsertTime.ToString("yyyy-MM-dd HH:mm:ss")</td>
                            <td>@item.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss")</td>
                            <td>
                                <div class="am-btn-toolbar">
                                    <div class="am-btn-group am-btn-group-xs">
                                        <button class="am-btn am-btn-default am-btn-xs am-text-secondary" data-id="@item.Id"><span class="am-icon-pencil-square-o"></span>编辑</button>
                                        <a class="am-btn am-btn-default am-btn-xs" name="btnDetail" data-id="@item.Id">详情</a>
                                        <button class="am-btn am-btn-default am-btn-xs am-text-danger"  data-id="@item.Id"><span class="am-icon-trash-o"></span>删除</button>
                                    </div>
                                </div>
                            </td>
                        </tr>
                            }
                        }
                    }


                </tbody>
            </table>
            <div class="am-cf"> 
                <div class="am-fr">
                    <ul class="am-pagination">
                        <li class="am-disabled"><a href="#">首页</a></li>
                        <li class="am-active"><a href="#">上一页</a></li>
                        @{
                            var allPage = ViewBag.allpage;
                            for (int i = 1; i <= allPage; i++)
                            {
                                if (i == ViewBag.pageNum)
                                {
                            <li><a href="#" class="am-active">@i</a></li>
                                }
                                else
                                {
                            <li><a href="#">@i</a></li>
                                }
                            }
                            
                            
                        }
                        <li class="am-disabled" id="nextPage"><a>下一页</a></li>
                        <li class="am-active"><a>尾页</a></li>

                        @* <li class="am-disabled"><a href="#">«</a></li>
                        <li class="am-active"><a href="#">1</a></li>
                        <li><a href="#">2</a></li>
                        <li><a href="#">3</a></li>
                        <li><a href="#">4</a></li>
                        <li><a href="#">5</a></li>
                        <li><a href="#">»</a></li>*@
                    </ul>
                </div>
            </div>
            <hr>
            @*<p>注：.....</p>*@
        </form>
    </div>
</div>
<script>
    $(function () {
        $("#btnAdd").click(function () {
            layer.open({
                type: 2,
                area: ['800px', '600px'],
                title: "发布公告",
                content: "/Notice/Insert"
            });
            $("a[name='btnDetail']").click(function () {
                layer.open({
                    type: 2,
                    area: ['800px', '600px'],
                    title: "详情页面",
                    content: "/Notice/Detaile/" + $(this).attr("data-id")
                });
            });
        });
    })
</script>
